(function() {
  app.controller('my_indexCtrl', function(toast, $scope, my_index, header_m, centerdilog, $state, $timeout, alertTip, tradeApi, my_zxg_v, local_m) {
    header_m.set({
      fun_l: function() {
        var goto = local_m.get('my_index_back') || 'home';
        local_m.set('my_index_back', 'home');
        $state.go(goto);
      }
    });

    $scope.com_list = my_index.list; // 列表项数据
    $scope.com_list_click = function(obj) { // 列表点击函数
      $state.go(obj.go);
    };

    $scope.init = function() {
      tradeApi.query({
        funcId: '300004',
        data: {}
      }).then(function(res) {
        $scope.client_fund_info = res;
      });
    };

    $scope.exit = function() {
      tradeApi.sessionId = '';
      sessionStorage.removeItem('session');
      my_zxg_v
        .updata('local');

      toast.ifVip(false);

      $state.go('home');
      alertTip
        .open({
          msg: '账户退出成功！',
          state: 1
        });
    };

    $scope.to_exit = function() {
      centerdilog
        .open({
          msg: '是否确认退出该账户?',
          ok: $scope.exit,
        });
    };


    $scope.toPay = function() {
      tradeApi.query({
        funcId: '300002',
        data: {}
      }).then(function(res) {
        $scope.client_info = res;
        if ($scope.client_info.client_type) {
          $state.go('pay');
        } else {
          alertTip.open({
            msg: '请先完善个人信息',
          });
          $timeout(function() {
            $state.go('my-info');
          }, 2000);
        }
      });
    };
  });

  app.value('my_index', {
    list: [
      {
        txt: '我的条件单',
        jiantou: true,
        url: false,
        go: 'myCondition'
      },
      {
      txt: '资金流水',
        jiantou: true,
        url: false,
        go: 'payflow'
      },
      {
        txt: '个人信息',
        jiantou: true,
        url: false,
        go: 'my-info'

      },
      {
        txt: '银行卡管理',
        jiantou: true,
        url: false,
        go: 'bank_m'

      },
      {
        txt: '修改密码',
        jiantou: true,
        url: false,
        go: 'change_psw'
      },
    ]
  });
})();